package com.pqc.tbk.dao.money;

import javax.persistence.Query;

import org.springframework.stereotype.Repository;

import com.pqc.tbk.dao.BaseDaoSupport;
import com.pqc.tbk.entity.ConstProp;
import com.pqc.tbk.entity.money.ConfirmMoneyOut;

/**
 * 
 * @author long, create on 2012-8-2 上午12:55:03
 * 
 */
@Repository
public class ConfirmMoneyOutDaoImpl extends BaseDaoSupport<ConfirmMoneyOut>
		implements ConfirmMoneyOutDao {

	@Override
	public Long countByUidAndState(final Long uid) {
		final String hql = "select count(*) from ConfirmMoneyOut where uid=? and (state=? or state=?)";
		final Query query = em.createQuery(hql);
		query.setParameter(1, uid);
		query.setParameter(2, ConstProp.ConfirmMoneyInout.TO_APPLY);
		query.setParameter(3, ConstProp.ConfirmMoneyInout.HAVE_APPLY);
		return (Long) query.getSingleResult();
	}
}
